home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol A-4 / (Vol A-4) Vol. A4.iso / Games / selfstorage.swf / scripts / frame_5 / PlaceObject2_184_456 / CLIPACTIONRECORD onClipEvent(enterFrame).as < prev    next >
Text File  |  2008-03-17  |  19KB  |  473 lines

  1. onClipEvent(enterFrame){
  2.    if(_root.int_spiellaeuft == 1)
  3.    {
  4.       if(int_aktiviert == 1)
  5.       {
  6.          int_soundwartecounter--;
  7.          int_aufschlag = 0;
  8.          if(dragging == 0)
  9.          {
  10.             v_y += 2 * g;
  11.             this._y += v_y;
  12.             if(this._y > _root.mc_box0._y + 100)
  13.             {
  14.                if(_root.int_soundon == 1)
  15.                {
  16.                   _root.mc_sounds.crash.start(0,1);
  17.                }
  18.                if(_root.int_boxennummer == this.int_boxennummer)
  19.                {
  20.                   _root.int_boxennummer = _root.int_boxennummer + 1;
  21.                   _root.mc_box.duplicateMovieClip("mc_box" + _root.int_boxennummer,_root.int_boxennummer);
  22.                   _root["mc_box" + _root.int_boxennummer].int_boxennummer = _root.int_boxennummer;
  23.                   _root["mc_box" + _root.int_boxennummer].int_aktiviert = 0;
  24.                   _root["mc_box" + _root.int_boxennummer]._y = 160;
  25.                   _root["mc_box" + _root.int_boxennummer]._x = buehnenbreite + 100;
  26.                   _root["mc_box" + _root.int_boxennummer].int_nr_box = _root.int_boxennummer;
  27.                   _root["mc_box" + _root.int_boxennummer]._rotation = 0;
  28.                }
  29.                var arr_liegereihenfolge_zwischenspeicher = new Array();
  30.                ar = 0;
  31.                while(ar < _root.arr_liegereihenfolge.length)
  32.                {
  33.                   if(int(_root.arr_liegereihenfolge[ar]) != int_nr_box)
  34.                   {
  35.                      arr_liegereihenfolge_zwischenspeicher.push(_root.arr_liegereihenfolge[ar]);
  36.                   }
  37.                   ar++;
  38.                }
  39.                _root.arr_liegereihenfolge = arr_liegereihenfolge_zwischenspeicher;
  40.                this.removeMovieClip();
  41.             }
  42.             this._x += v_x;
  43.             if(v_y > 0)
  44.             {
  45.                v_y -= lftw;
  46.             }
  47.             if(v_y < 0)
  48.             {
  49.                v_y += lftw;
  50.             }
  51.             if(v_y < lftw && v_y > - lftw)
  52.             {
  53.                v_y = 0;
  54.             }
  55.             if(v_x > 0)
  56.             {
  57.                v_x -= lftw;
  58.             }
  59.             if(v_x < 0)
  60.             {
  61.                v_x += lftw;
  62.             }
  63.             if(v_x < lftw && v_x > - lftw)
  64.             {
  65.                v_x = 0;
  66.             }
  67.          }
  68.          if(dragging == 1 && int_aufschlag == 0 && _root.int_boxennummer == this.int_boxennummer)
  69.          {
  70.             numb_lotabweichung = abweichungswinkel + startwinkel;
  71.             while(numb_lotabweichung > 180)
  72.             {
  73.                numb_lotabweichung -= 360;
  74.             }
  75.             while(numb_lotabweichung < -180)
  76.             {
  77.                numb_lotabweichung += 360;
  78.             }
  79.             numb_faktor_hebel = int(Math.sin(numb_lotabweichung * 3.141592653589793 / 180) * 100) / 100;
  80.             if(numb_lotabweichung < 0)
  81.             {
  82.                numb_faktor_hebel *= -1;
  83.             }
  84.             numb_rotationsbeschleunigung -= numb_lotabweichung / 5 * g * numb_faktor_hebel * (haltepunktdistanz / 100);
  85.          }
  86.          if(numb_rotationsbeschleunigung > 0)
  87.          {
  88.             numb_rotationsbeschleunigung -= lftw;
  89.          }
  90.          if(numb_rotationsbeschleunigung < 0)
  91.          {
  92.             numb_rotationsbeschleunigung += lftw;
  93.          }
  94.          if(dragging == 1 && _root.int_boxennummer == this.int_boxennummer)
  95.          {
  96.             numb_faktor_haltepunktdistanz = haltepunktdistanz / (this._width / 2);
  97.             if(numb_lotabweichung != 0 && numb_lotabweichung != 180)
  98.             {
  99.                v_x_faktor = numb_faktor_haltepunktdistanz * (int(v_x * Math.cos(numb_lotabweichung * 3.141592653589793 / 180)) / 5);
  100.                if(v_x_faktor < 0)
  101.                {
  102.                   v_x_faktor = v_x_faktor * v_x_faktor * -1;
  103.                }
  104.                else
  105.                {
  106.                   v_x_faktor *= v_x_faktor;
  107.                }
  108.                if(v_x_faktor < 10 && v_x_faktor > -10)
  109.                {
  110.                   numb_rotationsbeschleunigung += v_x_faktor;
  111.                }
  112.             }
  113.             if(numb_lotabweichung != 90 && numb_lotabweichung != -90)
  114.             {
  115.                v_y_faktor = numb_faktor_haltepunktdistanz * (int(v_y * Math.cos((numb_lotabweichung - 90) * 3.141592653589793 / 180)) / 5);
  116.                if(v_y_faktor < 0)
  117.                {
  118.                   v_x_faktor = v_y_faktor * v_y_faktor * -1;
  119.                }
  120.                else
  121.                {
  122.                   v_y_faktor *= v_y_faktor;
  123.                }
  124.                if(v_y_faktor < 10 && v_y_faktor > -10)
  125.                {
  126.                   numb_rotationsbeschleunigung += v_y_faktor;
  127.                }
  128.             }
  129.          }
  130.          if(int_objektliegt == 0 || _root.int_boxennummer != this.int_boxennummer)
  131.          {
  132.             startwinkel += numb_rotationsbeschleunigung;
  133.             if(int_sturzrotation == 0)
  134.             {
  135.                this._rotation = startwinkel + objektrotation;
  136.             }
  137.          }
  138.          if(this._y > buehnenhoehe - this._height / 2)
  139.          {
  140.             if(objektrotation > 0)
  141.             {
  142.                this._rotation -= 0;
  143.             }
  144.             if(objektrotation < 0)
  145.             {
  146.                this._rotation += 0;
  147.             }
  148.          }
  149.          if(dragging == 1 && _root.int_boxennummer == this.int_boxennummer)
  150.          {
  151.             int_objektliegt = 0;
  152.             v_y = this._y - ypos_save;
  153.             ypos_save = this._y;
  154.             v_x = this._x - xpos_save;
  155.             xpos_save = this._x;
  156.             xversatz = mausx * Math.sin((this._rotation + haltepunktwinkel) * 3.141592653589793 / 180);
  157.             yversatz = mausy * Math.cos((this._rotation - haltepunktwinkel + 90) * 3.141592653589793 / 180);
  158.             this._x = _root._xmouse - mausx;
  159.             this._y = _root._ymouse - mausy;
  160.             this._x = this._x + mausx + (- haltepunktdistanz) * Math.sin((this._rotation + haltepunktwinkel) * 3.141592653589793 / 180);
  161.             this._y = this._y + mausy - (- haltepunktdistanz) * Math.sin((this._rotation + haltepunktwinkel + 90) * 3.141592653589793 / 180);
  162.             if(this._y > buehnenhoehe - this._height / 2)
  163.             {
  164.                this._y = buehnenhoehe - this._height / 2;
  165.                int_haltepunktgesetzt = 0;
  166.                mausx = this._xmouse;
  167.                mausy = this._ymouse;
  168.                trace("\n\nMausX: " + mausx + "\nMausY: " + mausy);
  169.                vTan = Number(mausx) / Number(mausy);
  170.                arkusTanB = Math.atan(vTan);
  171.                haltepunktwinkel = (- arkusTanB / 3.141592653589793) * 180;
  172.                if(mausy >= 0)
  173.                {
  174.                   if(mausx > 0)
  175.                   {
  176.                      haltepunktwinkel += 180;
  177.                   }
  178.                   else
  179.                   {
  180.                      haltepunktwinkel -= 180;
  181.                   }
  182.                }
  183.                trace("haltepunktwinkel: " + haltepunktwinkel);
  184.                haltepunktdistanz = Math.sqrt(mausx * mausx + mausy * mausy);
  185.                objektrotation = this._rotation;
  186.                startwinkel = 0;
  187.                abweichungswinkel = haltepunktwinkel + this._rotation;
  188.                if(abweichungswinkel > 180)
  189.                {
  190.                   abweichungswinkel -= 360;
  191.                }
  192.                if(abweichungswinkel < -180)
  193.                {
  194.                   abweichungswinkel += 360;
  195.                }
  196.                trace("abweichungswinkel: " + abweichungswinkel);
  197.             }
  198.          }
  199.          int_boxenhit = 0;
  200.          j = 0;
  201.          while(j < int_boxennummer)
  202.          {
  203.             if(this.hitTest(_root["mc_box" + j]) && int_sturzrotation == 0)
  204.             {
  205.                if(_root.int_soundon == 1 && int_objektliegt == 0 && int_soundwartecounter <= 0)
  206.                {
  207.                   _root.mc_sounds.schritt.start(0,1);
  208.                   int_soundwartecounter = 5;
  209.                }
  210.                _root["mc_box" + j].numb_tiefsterpunkt = 0;
  211.                n = 1;
  212.                while(n <= 4)
  213.                {
  214.                   if(_root["mc_box" + j]["mc_ecke" + n]._y > _root["mc_box" + j].numb_tiefsterpunkt)
  215.                   {
  216.                      _root["mc_box" + j].numb_tiefsterpunkt = _root["mc_box" + j]["mc_ecke" + n]._y;
  217.                   }
  218.                   n++;
  219.                }
  220.                _root["mc_box" + j].numb_hoechsterpunkt = 0;
  221.                n = 1;
  222.                while(n <= 4)
  223.                {
  224.                   if(_root["mc_box" + j]["mc_ecke" + n]._y < _root["mc_box" + j].numb_hoechsterpunkt)
  225.                   {
  226.                      _root["mc_box" + j].numb_hoechsterpunkt = _root["mc_box" + j]["mc_ecke" + n]._y;
  227.                   }
  228.                   n++;
  229.                }
  230.                _root["mc_box" + j].numb_rechterpunkt = 0;
  231.                n = 1;
  232.                while(n <= 4)
  233.                {
  234.                   if(_root["mc_box" + j]["mc_ecke" + n]._x > _root["mc_box" + j].numb_rechterpunkt)
  235.                   {
  236.                      _root["mc_box" + j].numb_rechterpunkt = _root["mc_box" + j]["mc_ecke" + n]._x;
  237.                   }
  238.                   n++;
  239.                }
  240.                _root["mc_box" + j].numb_linkerpunkt = 0;
  241.                n = 1;
  242.                while(n <= 4)
  243.                {
  244.                   if(_root["mc_box" + j]["mc_ecke" + n]._x < _root["mc_box" + j].numb_linkerpunkt)
  245.                   {
  246.                      _root["mc_box" + j].numb_linkerpunkt = _root["mc_box" + j]["mc_ecke" + n]._x;
  247.                   }
  248.                   n++;
  249.                }
  250.                numb_tiefsterpunkt = 0;
  251.                i = 1;
  252.                while(i <= 4)
  253.                {
  254.                   if(this["ecke" + i + "Y"] > numb_tiefsterpunkt)
  255.                   {
  256.                      numb_tiefsterpunkt = this["ecke" + i + "Y"];
  257.                      int_tiefsteecke = i;
  258.                   }
  259.                   i++;
  260.                }
  261.                numb_tiefsterpunkt2 = 0;
  262.                i = 1;
  263.                while(i <= 4)
  264.                {
  265.                   if(this["ecke" + i + "Y"] > numb_tiefsterpunkt2 && i != int_tiefsteecke)
  266.                   {
  267.                      numb_zweittiefsterpunkt = this["ecke" + i + "Y"];
  268.                      int_zweittiefsteecke = i;
  269.                   }
  270.                   i++;
  271.                }
  272.                if(this._y + numb_tiefsterpunkt - 2 - 2 * v_y < _root["mc_box" + j]._y + _root["mc_box" + j].numb_hoechsterpunkt)
  273.                {
  274.                   var_hit_richtung = "oben";
  275.                }
  276.                else if(_root["mc_box" + j]._x + _root["mc_box" + j].numb_linkerpunkt > this._x)
  277.                {
  278.                   var_hit_richtung = "links";
  279.                }
  280.                else
  281.                {
  282.                   var_hit_richtung = "rechts";
  283.                }
  284.                if(var_hit_richtung == "links" || var_hit_richtung == "rechts")
  285.                {
  286.                   trace("HIT: " + var_hit_richtung);
  287.                   dragging = 0;
  288.                   this._x += v_x;
  289.                   _root["mc_box" + j].v_x = v_x;
  290.                   if(_root.int_boxennummer == this.int_boxennummer && int_boxenhit == 0 && int_seitenhit == 0)
  291.                   {
  292.                      this.v_x = v_x * -1;
  293.                      int_boxenhit = 1;
  294.                      int_seitenhit = 1;
  295.                   }
  296.                }
  297.                if(var_hit_richtung == "oben")
  298.                {
  299.                   dragging = 0;
  300.                   if(int_boxenhit == 0)
  301.                   {
  302.                      this._y -= v_y;
  303.                      int_boxenhit = 1;
  304.                   }
  305.                   _root["mc_box" + j].v_x = v_x / reibung;
  306.                   int_getroffenebox_nummer = j;
  307.                }
  308.             }
  309.             j++;
  310.          }
  311.          if(int_boxenhit == 1 && var_hit_richtung == "oben")
  312.          {
  313.             v_y = v_y * -1 / elastizitaet;
  314.             v_x /= reibung;
  315.             int_aufschlag = 1;
  316.             i = 1;
  317.             while(i <= 4)
  318.             {
  319.                numb_eckdistanz = Math.sqrt(this["mc_ecke" + i]._x * this["mc_ecke" + i]._x + this["mc_ecke" + i]._y * this["mc_ecke" + i]._y);
  320.                vTan = Number(this["mc_ecke" + i]._x) / Number(this["mc_ecke" + i]._y);
  321.                arkusTanB = Math.atan(vTan);
  322.                numb_eckwinkel = (- arkusTanB / 3.141592653589793) * 180;
  323.                if(this["mc_ecke" + i]._y >= 0)
  324.                {
  325.                   if(this["mc_ecke" + i]._x > 0)
  326.                   {
  327.                      numb_eckwinkel += 180;
  328.                   }
  329.                   else
  330.                   {
  331.                      numb_eckwinkel -= 180;
  332.                   }
  333.                }
  334.                this["ecke" + i + "X"] = numb_eckdistanz * Math.sin((this._rotation + numb_eckwinkel) * 3.141592653589793 / 180);
  335.                this["ecke" + i + "Y"] = numb_eckdistanz * Math.sin((this._rotation - 90 + numb_eckwinkel) * 3.141592653589793 / 180);
  336.                i++;
  337.             }
  338.             numb_tiefsterpunkt = 0;
  339.             i = 1;
  340.             while(i <= 4)
  341.             {
  342.                if(this["ecke" + i + "Y"] > numb_tiefsterpunkt)
  343.                {
  344.                   numb_tiefsterpunkt = this["ecke" + i + "Y"];
  345.                   int_tiefsteecke = i;
  346.                }
  347.                i++;
  348.             }
  349.             numb_tiefsterpunkt2 = 0;
  350.             i = 1;
  351.             while(i <= 4)
  352.             {
  353.                if(this["ecke" + i + "Y"] > numb_tiefsterpunkt2 && i != int_tiefsteecke)
  354.                {
  355.                   numb_zweittiefsterpunkt = this["ecke" + i + "Y"];
  356.                   int_zweittiefsteecke = i;
  357.                }
  358.                i++;
  359.             }
  360.             if(_root.int_boxennummer == this.int_boxennummer)
  361.             {
  362.                _root.mc_schwerpunktlinie._x = this._x;
  363.                if(_root.mc_schwerpunktlinie.hitTest(_root["mc_box" + int_getroffenebox_nummer]))
  364.                {
  365.                   int_absturz = 0;
  366.                }
  367.                else
  368.                {
  369.                   int_absturz = 1;
  370.                   if(_root.mc_schwerpunktlinie._x < _root["mc_box" + int_getroffenebox_nummer]._x)
  371.                   {
  372.                      numb_rotationsbeschleunigung += (_root.mc_schwerpunktlinie._x - (_root["mc_box" + int_getroffenebox_nummer]._x - _root["mc_box" + int_getroffenebox_nummer]._width / 2)) / 10;
  373.                      v_x += (_root.mc_schwerpunktlinie._x - (_root["mc_box" + int_getroffenebox_nummer]._x - _root["mc_box" + int_getroffenebox_nummer]._width / 2)) / 10;
  374.                      _root["mc_box" + int_getroffenebox_nummer].v_x = v_x / reibung * -1;
  375.                   }
  376.                   else
  377.                   {
  378.                      numb_rotationsbeschleunigung += (_root.mc_schwerpunktlinie._x - (_root["mc_box" + int_getroffenebox_nummer]._x + _root["mc_box" + int_getroffenebox_nummer]._width / 2)) / 10;
  379.                      v_x += (_root.mc_schwerpunktlinie._x - (_root["mc_box" + int_getroffenebox_nummer]._x + _root["mc_box" + int_getroffenebox_nummer]._width / 2)) / 10;
  380.                      _root["mc_box" + int_getroffenebox_nummer].v_x = v_x / reibung * -1;
  381.                   }
  382.                   trace("Absturz");
  383.                }
  384.             }
  385.             if(int_absturz == 0)
  386.             {
  387.                aufschlag_dreh_faktor = this["ecke" + int_tiefsteecke + "X"] * 2 / (this._width / 2);
  388.                numb_rotationsbeschleunigung = (v_y / 5 - 0.5) * numb_gewicht * aufschlag_dreh_faktor;
  389.                if(numb_tiefsterpunkt - numb_zweittiefsterpunkt < 20 && v_y > -1.5 && v_y < 0.5)
  390.                {
  391.                   numb_rotationsbeschleunigung /= 2;
  392.                }
  393.                if(numb_tiefsterpunkt - numb_zweittiefsterpunkt < 10 && v_y > -1.5 && v_y < 0.5)
  394.                {
  395.                   numb_rotationsbeschleunigung /= 2;
  396.                }
  397.                if(numb_tiefsterpunkt - numb_zweittiefsterpunkt < 4 && v_y > -1.5 && v_y < 0.5)
  398.                {
  399.                   int_objektliegt = 1;
  400.                   if(int_sturzrotation == 0)
  401.                   {
  402.                      if(this._rotation > -10 && this._rotation < 10)
  403.                      {
  404.                         this._rotation = 0;
  405.                      }
  406.                      if(this._rotation > -100 && this._rotation < -80)
  407.                      {
  408.                         this._rotation = -90;
  409.                      }
  410.                      if(this._rotation > 80 && this._rotation < 100)
  411.                      {
  412.                         this._rotation = 90;
  413.                      }
  414.                      if(this._rotation > 170 || this._rotation < -170)
  415.                      {
  416.                         this._rotation = 180;
  417.                      }
  418.                   }
  419.                   if(_root.int_boxennummer == this.int_boxennummer)
  420.                   {
  421.                      _root.numb_maxhoehe = 0;
  422.                      b = 1;
  423.                      while(b <= _root.int_boxennummer)
  424.                      {
  425.                         if(_root.mc_box0._y - _root["mc_box" + b]._y > _root.numb_maxhoehe)
  426.                         {
  427.                            _root.numb_maxhoehe = _root.mc_box0._y - _root["mc_box" + b]._y;
  428.                            _root.numb_hoeheimbildY = _root["mc_box" + b]._y;
  429.                         }
  430.                         b++;
  431.                      }
  432.                      trace("Max Hoehe: " + _root.numb_maxhoehe);
  433.                      trace("Hoehe im Bild: " + _root.numb_hoeheimbildY);
  434.                   }
  435.                   if(_root.int_boxennummer == this.int_boxennummer)
  436.                   {
  437.                      _root.arr_liegereihenfolge.push(int_nr_box);
  438.                      trace(_root.arr_liegereihenfolge);
  439.                      _root.int_boxennummer = _root.int_boxennummer + 1;
  440.                      _root.mc_box.duplicateMovieClip("mc_box" + _root.int_boxennummer,_root.int_boxennummer);
  441.                      _root["mc_box" + _root.int_boxennummer].int_boxennummer = _root.int_boxennummer;
  442.                      _root["mc_box" + _root.int_boxennummer].int_aktiviert = 0;
  443.                      _root["mc_box" + _root.int_boxennummer]._y = 160;
  444.                      _root["mc_box" + _root.int_boxennummer]._x = buehnenbreite + 100;
  445.                      _root["mc_box" + _root.int_boxennummer].int_nr_box = _root.int_boxennummer;
  446.                      _root["mc_box" + _root.int_boxennummer]._rotation = 0;
  447.                   }
  448.                }
  449.             }
  450.          }
  451.          if(dragging == 1)
  452.          {
  453.             if(int_haltepunktgesetzt == 0)
  454.             {
  455.                int_haltepunktgesetzt = 1;
  456.             }
  457.             _parent.mc_haltepunkt._x = _parent._xmouse;
  458.             _parent.mc_haltepunkt._y = _parent._ymouse;
  459.          }
  460.          else
  461.          {
  462.             int_haltepunktgesetzt = 0;
  463.          }
  464.       }
  465.    }
  466.    if(this.int_aktiviert == 0 && _root.int_boxennummer == this.int_boxennummer && this._x > buehnenbreite - 80)
  467.    {
  468.       this._x -= 8;
  469.       this._y = 200 - this._height / 2;
  470.       _root.mc_foerderband.play();
  471.    }
  472. }
  473.